package com.cn.yz.springboot.util.tablesplit.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

import com.cn.yz.springboot.util.tablesplit.Strategy;

/**
 * 按年分表
 * @author king
 *
 */
public class YYYYStrategy implements Strategy {
	
	private Logger logger = LoggerFactory.getLogger(YYYYStrategy.class);

	@Override
	public String convert(Map<String, Object> params) throws Exception {
		SimpleDateFormat sdf = new SimpleDateFormat("YYYY");
		
		StringBuilder sb=new StringBuilder(params.get(Strategy.TABLE_NAME).toString());
		sb.append("_");
		sb.append(sdf.format(new Date()));
		return sb.toString();
	}

}
